package com.moshang.mall.product.web;

import com.moshang.mall.product.entity.CategoryEntity;
import com.moshang.mall.product.entity.vo.Catalog2Vo;
import com.moshang.mall.product.service.CategoryService;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

/**
 * @Author xww
 * @Description //TODO
 * @Date 2020/9/8   15:50
 **/
@Controller
public class IndexController {
    @Resource
    private CategoryService categoryService;

    @GetMapping({"/","/index.html"})
    public String index(Model model){
      List<CategoryEntity>  categorys= categoryService.getLeve1Cate();
      model.addAttribute("categorys",categorys);
        return  "index";
    }
    @GetMapping("index/catalog.json")
    @ResponseBody
    public Map<String, List<Catalog2Vo>> catalog(){
        return categoryService.getCatalogJson();
    }
}
